package com.tommy.foreground.controller;

import com.tommy.foreground.entity.Item;
import com.tommy.foreground.service.ItemService;
import com.wordnik.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

/**
 * @Package Name: com.tommy.foreground.controller
 * @Description: TODO
 * @Author tommy
 * @Date 2017.11.10 15:35
 * @Modify Who      When     What
 * ---------- ----------- ------------- 
 */
@Api(value = "/shop/item", description = "operation about tb_item")
@Controller
@RequestMapping("/api/v1/shop/")
public class ItemController {

    @Autowired
    private ItemService itemService;

    @ApiOperation(value = "根据商品 id 查询商品详情", notes = "暂无",httpMethod = "GET")
    @ApiImplicitParam(name = "itemId",value = "商品ID",required = true,dataType = "Long",paramType = "path")
    @GetMapping("item/{itemId}")
    @ResponseBody
    public Item queryItem(@PathVariable Long itemId) {
        return itemService.selectItemInfo(itemId);
    }

    @ApiOperation(value = "hello world", notes = "暂无",httpMethod = "POST")
    @PostMapping(value = "/hello")
    //@ResponseBody
    public String hello(@RequestBody Item item) {
        System.out.println(item);
        return "Hello World";
    }
}
